package com.dykj.fireFighting.server.socialUnit.outdoorDevice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dykj.fireFighting.api.socialUnit.occupiedvideo.dto.OccupiedVideoDto;
import com.dykj.fireFighting.api.socialUnit.occupiedvideo.entity.OccupiedVideo;
import com.dykj.fireFighting.api.socialUnit.outdoorDevice.dto.OutdoorDeviceDto;
import com.dykj.fireFighting.api.socialUnit.outdoorDevice.entity.OutdoorDevice;
import com.dykj.fireFighting.api.socialUnit.outdoorDevice.service.IOutdoorDeviceService;
import com.dykj.fireFighting.common.core.service.impl.BaseServiceImpl;
import com.dykj.fireFighting.common.core.vo.PageVo;
import com.dykj.fireFighting.server.socialUnit.outdoorDevice.mapper.OutdoorDeviceMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 *
 * @Author JacksonTu
 * @Date  2021-08-18 10:06:42
 */
@Slf4j
@DubboService
@Transactional(rollbackFor = Exception.class)
public class OutdoorDeviceServiceImpl extends BaseServiceImpl<OutdoorDeviceMapper, OutdoorDevice> implements IOutdoorDeviceService {
    @Override
    public List<OutdoorDevice> queryList(OutdoorDeviceDto outdoorDeviceDto) {
        QueryWrapper<OutdoorDevice> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("unit_id",outdoorDeviceDto.getUnitId());
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public PageVo<OutdoorDevice> queryListPage(OutdoorDeviceDto outdoorDeviceDto) {
        HashMap<String , Object> params = new HashMap<>(16);
        params.put("unitId",outdoorDeviceDto.getUnitId());
        params.put("address",outdoorDeviceDto.getAddress());
        params.put("name",outdoorDeviceDto.getName());
        params.put("zrr",outdoorDeviceDto.getZrr());
        Page page = new Page();
        // 设置当前页码
        page.setCurrent(outdoorDeviceDto.getPage());
        // 设置页大小
        page.setSize(outdoorDeviceDto.getLimit());
        return new PageVo<OutdoorDevice>(this.baseMapper.queryList(page,params));
    }
}
